package cn.wl.pchart.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// 资源文件配置类
@Configuration
public class ResourceConfig implements WebMvcConfigurer {

    @Value("${pchart.storage.path: #{null}}")
    private String path;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //第一个方法设置访问路径前缀，第二个方法设置资源路径
        registry.addResourceHandler("/" + path + "/**").addResourceLocations("file:///" + System.getProperty("user.dir") + "/" + path + "/");

    }
}
